package CollectionsFramework;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public  class ConcurrentModificationExceptionTest {
    public  static void main(String[] args) {
        final List<Integer> nums = new ArrayList<>();
        for (int i = 0; i < 1000000; i++) {
            nums.add(new Random().nextInt(10000000));
        }
        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                for (Integer num : nums) {
                    if (num > 1000000) {
                        nums.remove(num);
                    }
                }
            }).start();
        }


    }
}

